import React, { Component } from 'react'
import Input from './components/Input'

class Index extends Component {
    constructor(props) {
        super(props)
        this.state = {
            username: '',
            password: ''
        }
    }
    changeUsername(e) {
        this.setState({ username: e.target.value })
    }
    changePassword(e) {
        this.setState({ password: e.target.value })
    }
    submit() {
        const { username, password } = this.state
        console.log('~~提交信息', { username, password })
    }
    render() {
        const { username, password } = this.state
        return (
            <div>
                {/* onChange必须驼峰，不能原生写法 */}
                <Input placeholder='请输入用户名' value={username} onChange={e=>this.changeUsername(e)} />
                <Input placeholder='请输入密码' value={password} type='password' onChange={e=>this.changePassword(e)} />
                <button onClick={()=>this.submit()}>submit</button>
            </div>
        );
    }
}

export default Index;
